home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Applications / Macintosh Tracker 1.20 / source / Server⁄Tracker 4.0 / mac_hack.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-23  |  6.1 KB  |  250 lines  |  [TEXT/KAHL]

  1. /* mac_hack.h */
  2.  
  3. #pragma once
  4.  
  5. /* All the stuff in this file was written by Thomas R. Lawrence. */
  6. /* See the "mac_readme" or "mac_programmer_info" files for more information */
  7. /* about the Macintosh port */
  8.  
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. #include <string.h>
  12. #include <ctype.h>
  13. #include <math.h>
  14. #include <unix.h>
  15.  
  16. /********************************************************************************/
  17. /* High-level hackery */
  18.  
  19.  
  20. int MYprintf(...);
  21. #define printf MYprintf
  22.  
  23. int MYfprintf(...);
  24. #define fprintf MYfprintf
  25.  
  26.  
  27. /* note: this structure supports reading only.  There is no copyback of dirty info */
  28. #define FILEBUFFERSIZE (4096)
  29. typedef struct
  30.     {
  31.         short            MacFileHandle;
  32.         short            BufPtr;
  33.         long            Index;
  34.         long            EndOfFile;
  35.         char            Buffer[FILEBUFFERSIZE];
  36.     } MyFILE;
  37.  
  38. #define FILE MyFILE
  39.  
  40. int MYfgetc(FILE* FileToGetFrom);
  41. #define fgetc(FileToGetFrom)\
  42. (((FileToGetFrom->BufPtr != FILEBUFFERSIZE)\
  43.     && (FileToGetFrom->Index < FileToGetFrom->EndOfFile))\
  44. ?\
  45.     (\
  46.         FileToGetFrom->BufPtr += 1,\
  47.         FileToGetFrom->Index += 1,\
  48.         (int)(unsigned char)FileToGetFrom->Buffer[FileToGetFrom->BufPtr - 1]\
  49.     )\
  50. :\
  51.     (MYfgetc(FileToGetFrom)))
  52.  
  53. int MYfputc(int CharToPut, FILE *FileToPutTo);
  54. #define fputc MYfputc
  55.  
  56. FILE* MYfopen(char* FileName, char* Mode);
  57. #define fopen MYfopen
  58.  
  59. int MYfclose(FILE* FileToClose);
  60. #define fclose MYfclose
  61.  
  62. int MYfread(char* PlaceToPut, int SizeOfElement, int NumElements, FILE* TheFile);
  63. #define fread MYfread
  64.  
  65. void* MYmalloc(long SizeOfBlock);
  66. #define malloc MYmalloc
  67.  
  68. void MYfree(void* Block);
  69. #define free MYfree
  70.  
  71. /* to allow for my own antialiasing-friendly readin routine */
  72. void *MYcalloc(size_t NumThings, size_t SizeOfThing);
  73. #define calloc MYcalloc
  74.  
  75. #define fflush(stupid)
  76.  
  77. void MYexit(int Value);
  78. #define exit MYexit
  79.  
  80. char* MYgetenv(char* MeaninglessParameter);
  81. #define getenv MYgetenv
  82.  
  83. void MYperror(char* ErrorMessage);
  84. #define perror MYperror
  85.  
  86. void MYputs(char* Message);
  87. #define puts MYputs
  88.  
  89. #undef putchar
  90. #define putchar(thang)
  91.  
  92. #undef getchar
  93. #define getchar(thang)
  94.  
  95. #undef stdin
  96. #define stdin NULL
  97. #undef stdout
  98. #define stdout NULL
  99. #undef stderr
  100. #define stderr NULL
  101.  
  102. #undef isalnum
  103. #define isalnum(x) 0
  104. #undef isalpha
  105. #define isalpha(x) 0
  106. #undef iscntrl
  107. #define iscntrl(x) 0
  108. #undef isdigit
  109. #define isdigit(x) 0
  110. #undef isgraph
  111. #define isgraph(x) 0
  112. #undef islower
  113. #define islower(x) 0
  114. #undef isprint
  115. #define isprint(x) 0
  116. #undef ispunct
  117. #define ispunct(x) 0
  118. #undef isspace
  119. #define isspace(x) 0
  120. #undef isupper
  121. #define isupper(x) 0
  122. #undef isxdigit
  123. #define isxdigit(x) 0
  124.  
  125. #define NDEBUG /* for assert */
  126.  
  127. long double MYfloor(long double Base);
  128. #define floor MYfloor
  129.  
  130. long double MYpow(long double Base, long double Exponent);
  131. #define pow MYpow
  132.  
  133.  
  134. /********************************************************************************/
  135.  
  136.  
  137.  
  138. /*#include "defs.h"*/
  139. #define BOOL int  /* taken from "defs.h"; #undef'd later in this file */
  140.  
  141. #undef LOCAL
  142.  
  143. #undef NULL
  144. #define NULL (0L)
  145.  
  146. /* prototypes */
  147.  
  148. struct channel;
  149. struct event;
  150.  
  151. /* altered_audio.c */
  152. void init_tables(int oversample, int frequency);
  153. void reset_note(struct channel *ch, int note, int pitch);
  154. void set_current_pitch(struct channel *ch, int pitch);
  155. void set_current_volume(struct channel *ch, int volume);
  156.  
  157. /* automaton.c */
  158. /* void init_automaton(struct automaton *a, struct song *song, int start, BOOL s); */
  159. void next_tick(struct automaton *a);
  160.  
  161. /* commands.c */
  162. void do_nothing(struct channel *ch);
  163. void do_slide(struct channel *ch);
  164. void do_vibrato(struct channel *ch);
  165. void do_arpeggio(struct channel *ch);
  166. void do_slidevol(struct channel *ch);
  167. void do_retrig(struct channel *ch);
  168. void do_latestart(struct channel *ch);
  169. void do_cut(struct channel *ch);
  170. void do_portamento(struct channel *ch);
  171. void do_portaslide(struct channel *ch);
  172. void do_vibratoslide(struct channel *ch);
  173. void set_nothing(struct automaton *a, struct channel *ch);
  174. void set_upslide(struct automaton *a, struct channel *ch);
  175. void set_downslide(struct automaton *a, struct channel *ch);
  176. void set_vibrato(struct automaton *a, struct channel *ch);
  177. void set_arpeggio(struct automaton *a, struct channel *ch);
  178. void set_slidevol(struct automaton *a, struct channel *ch);
  179. void set_extended(struct automaton *a, struct channel *ch);
  180. void set_portamento(struct automaton *a, struct channel *ch);
  181. void set_portaslide(struct automaton *a, struct channel *ch);
  182. void set_vibratoslide(struct automaton *a, struct channel *ch);
  183. void set_speed(struct automaton *a, struct channel *ch);
  184. void set_skip(struct automaton *a, struct channel *ch);
  185. void set_fastskip(struct automaton *a, struct channel *ch);
  186. void set_offset(struct automaton *a, struct channel *ch);
  187. void set_volume(struct automaton *a, struct channel *ch);
  188. void parse_slidevol(struct channel *ch, int para);
  189. void init_effects(void (*table[])());
  190.  
  191. /* dump_song.c */
  192. void dump_song(struct song *song);
  193.  
  194. /* getopt.c */
  195. int getopt(int argc, char *argv[], struct long_option *options);
  196.  
  197. /* macintosh_audio.c */
  198. void      set_mix(int percent);
  199. int       open_audio(int SampleRate, int StereoFlag);
  200. void      actually_flush_buffer(void);
  201. void      flush_buffer(void);
  202. void      close_audio(void);
  203. void      set_synchro(int s);
  204. int       update_frequency(void);
  205. void      discard_buffer(void);
  206. void      resample(int oversample, int number);
  207.  
  208. /* main.c */
  209. void      end_all(char *s);
  210.  
  211. /* notes.c */
  212. int find_note(int pitch);
  213. void create_notes_table(void);
  214. int transpose_song(struct song *s, int transpose);
  215.  
  216. /* open.c */
  217. struct exfile;
  218. struct exfile *open_file(char *fname, char *fmode, char *path);
  219. void close_file(struct exfile *file);
  220.  
  221. /* player.c */
  222. void init_player(int o, int f);
  223.  
  224. /* read.c */
  225. void release_song(struct song *song);
  226. struct song *read_song(struct exfile *f, int type);
  227.  
  228. /* setup_audio.c */
  229. /* void setup_audio(int f, BOOL s, int o, BOOL sync); */
  230. void do_close_audio(void);
  231.  
  232. /* tools.c */
  233. int read_env(char *name, int def);
  234.  
  235. /* termio.c KLUDGES */
  236. BOOL run_in_fg(void);
  237. void sane_tty(void);
  238. void nonblocking_io(void);
  239. void* popen(char* pipe, char* Mode);
  240. void pclose(FILE* file);
  241. int may_getchar(void);
  242.  
  243.  
  244. /* to allow for my own main routine */
  245. #define main main2
  246. int main2(int argc, char **argv);
  247.  
  248.  
  249. #undef BOOL  /* must get rid of it because a typedef comes later */
  250.